import { updateAutoCheckEndOrder } from '@/api/network'
import { Ref, ref } from 'vue'

export default function (ids: Ref<Array<string>>) {
  // 批量自动审核结单策略加载
  const autoCheckEndOrderLoading = ref(false)

  // 是否自动审核结单：false-手动审核，true-自动审核
  const autoCheckEndOrder = ref(true)

  // 批量自动审核结单策略方法
  const autoCheckEndOrderFn = async () => {
    autoCheckEndOrderLoading.value = true
    const res = await updateAutoCheckEndOrder(autoCheckEndOrder.value, ids.value)
    autoCheckEndOrderLoading.value = false
    return res.data as { code: number; data: object; message: string; success: boolean }
  }

  return {
    autoCheckEndOrder,
    autoCheckEndOrderLoading,
    autoCheckEndOrderFn,
  }
}
